package com.baselibrary.view;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;


public class SpacesTopDec extends RecyclerView.ItemDecoration {
    private int space;
    private boolean isIncludeTop;

    public SpacesTopDec(int space, boolean isIncludeTop) {
        this.space = space;
        this.isIncludeTop = isIncludeTop;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        int position = parent.getChildAdapterPosition(view);
        if (isIncludeTop) {
            outRect.top = space;
        } else {
            if (position != 0) {
                outRect.top = space;
            }
        }
    }
}